package culosic.mdpocket.html;

import culosic.mdpocket.core.*;

public class HtmlFactory implements Factory {

	@Override
	public HtmlNode createNodeTextNoParse(String text) {
		return new NodeText(text);
	}

	@Override
	public HtmlNode createNodeCode() {
		return new NodeCode();
	}

	@Override
	public HtmlNode createNodeImg(String src, String alt, String title) {
		return new NodeImg(src, alt, title);
	}

	@Override
	public HtmlNode createNodeImg(String src, String alt) {
		return new NodeImg(src, alt);
	}

	@Override
	public HtmlNode createNodeA(String href) {
		return new NodeA(href);
	}

	@Override
	public HtmlNode createNodeA(String href, String title) {
		return new NodeA(href, title);
	}

	@Override
	public HtmlNode createNodeTr() {
		return new NodeTr();
	}

	@Override
	public HtmlNode createNodeTd() {
		return new NodeTd();
	}

	@Override
	public HtmlNode createNodeTable() {
		return new NodeTable();
	}

	@Override
	public HtmlNode createNodeTh() {
		return new NodeTh();
	}

	@Override
	public HtmlNode createNodeUl() {
		return new NodeUl();
	}

	@Override
	public HtmlNode createNodeOl() {
		return new NodeOl();
	}

	@Override
	public HtmlNode createNodeLi() {
		return new NodeLi();
	}

	@Override
	public HtmlNode createNodeEmStrong() {
		return new NodeEmStrong();
	}

	@Override
	public HtmlNode createNodeEm() {
		return new NodeEm();
	}

	@Override
	public HtmlNode createNodeH(int level) {
		return new NodeH(level);
	}

	@Override
	public HtmlNode createRoot() {
		return new Root();
	}

	@Override
	public HtmlNode createNodeText(String text) {
		text = text.replaceAll("\\\\(\\||`|#|`|\\\\|\\*|_|\\+|\\-|\\[|\\]|\\(|\\)|\\{|\\}|\\.|!)", "$1");
		text = text.replaceAll("&", "&amp;");
		text = text.replaceAll("<", "&lt;");
		text = text.replaceAll(">", "&gt;");
		return new NodeText(text);
	}

	@Override
	public HtmlNode createNodeStrong() {
		return new NodeStrong();
	}

	@Override
	public HtmlNode createNodePre(String lang) {
		return new NodePre(lang);
	}

	@Override
	public HtmlNode createNodeBlockquote() {
		return new NodeBlockQuote();
	}

}
